package live.zs.mybatisboot.service.impl;

import live.zs.mybatisboot.dto.PageInfo;
import live.zs.mybatisboot.entity.TbUser;
import live.zs.mybatisboot.repo.TbUserDao;
import live.zs.mybatisboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author madison
 * @description
 * @date 2021/7/8 23:31
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private TbUserDao userDao;

    @Override
    public PageInfo<TbUser> selectUsers(PageInfo pageInfo) {
        List<TbUser> tbUsers = userDao.selectPage(pageInfo);
        pageInfo.setTotal(userDao.selectCount(null));
        pageInfo.setData(tbUsers);
        return pageInfo;
    }

    @Override
    public int saveUser(TbUser user) {
        return userDao.insertSelective(user);
    }
}
